/*

Server Side Validation Library: A C# library for validation.
Copyright (C) 2006  Chad Finsterwald, CoreWeb

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/

using System;
using System.Collections.Generic;
using System.Text;

namespace CoreWebLibrary.Validation.Web
{
    public class BrokenRulesStyleCollection : Dictionary<int, StyleItem>
    {
        public BrokenRulesStyleCollection()
        {
        }

        public void AddInlineStyle(string key, string value, params System.Type[] applyToTypes)
        {
            StyleItem si = new InlineStyle( key, value, applyToTypes ) ;
            Add(si);
        }

        public void AddCssStyle(string normalCss, string errorCss, params System.Type[] applyToTypes)
        {
            StyleItem si = new ClassStyle(normalCss, errorCss, applyToTypes);
            Add(si);
        }

        public void Add(string keyOrNormalCss, string valueOrErrorCss, StyleItemType styleItemType,
            params System.Type[] applyToTypes)
        {
            switch (styleItemType)
            {
                case StyleItemType.Inline :
                    AddInlineStyle(keyOrNormalCss, valueOrErrorCss, applyToTypes);
                break;

                case StyleItemType.Class :
                    AddCssStyle(keyOrNormalCss, valueOrErrorCss, applyToTypes);
                break;

                default:
                    throw new ApplicationException("Unrecognized StyleItemType: " + styleItemType.ToString() + ".");
            }
        }

        public void Add(StyleItem si)
        {
            Add(si.GetHashCode(), si);
        }
    }
}
